package com.hy.demo.learn.proxy;

/**
 * <p>
 *
 * </p>
 *
 * @author cjl
 * @version 1.0
 * @since 2020-08-18 13:57
 */
public class PersonServiceProxy implements PersonService {

    private Transaction   transaction;
    private PersonService personService;

    public PersonServiceProxy(PersonService personService,Transaction transaction){
        this.personService = personService;
        this.transaction = transaction;
    }
    @Override
    public void insertPerson() {
        transaction.beginTransaction();
        personService.insertPerson();
        transaction.commitTransaction();
    }

    @Override
    public void updatePerson() {
        transaction.beginTransaction();
        personService.updatePerson();
        transaction.commitTransaction();
    }

    @Override
    public void deletePerson() {
        transaction.beginTransaction();
        personService.deletePerson();
        transaction.commitTransaction();
    }
}
